Learn R Programming

bnlearn (version 4.9.1)

graph utilities: Utilities to manipulate graphs

Description

Check and manipulate graph-related properties of an object of class bn.

Usage

# check whether the graph is acyclic/completely directed.
acyclic(x, directed = FALSE, debug = FALSE)
directed(x)
# check whether there is a path between two nodes.
path.exists(x, from, to, direct = TRUE, underlying.graph = FALSE, debug = FALSE)
# build the skeleton or a complete orientation of the graph.
skeleton(x)
pdag2dag(x, ordering)
# build a subgraph spanning a subset of nodes.
subgraph(x, nodes)

Value

acyclic(), path() and directed() return a boolean value.

skeleton(), pdag2dag() and subgraph() return an object of class bn.

Arguments

x

an object of class bn. skeleton(), acyclic(), directed() and path.exixsts() also accept objects of class bn.fit.

from

a character string, the label of a node.

to

a character string, the label of a node (different from from).

direct

a boolean value. If FALSE ignore any arc between from and to when looking for a path.

underlying.graph

a boolean value. If TRUE the underlying undirected graph is used instead of the (directed) one from the x argument.

ordering

the labels of all the nodes in the graph; their order is the node ordering used to set the direction of undirected arcs.

nodes

the labels of the nodes that induce the subgraph.

directed

a boolean value. If TRUE only completely directed cycles are considered; otherwise undirected arcs will also be considered and treated as arcs present in both directions.

debug

a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.

Author

Marco Scutari

References

Bang-Jensen J, Gutin G (2009). Digraphs: Theory, Algorithms and Applications. Springer, 2nd edition.

Examples

Run this code
data(learning.test)
cpdag = pc.stable(learning.test)

acyclic(cpdag)
directed(cpdag)
dag = pdag2dag(cpdag, ordering = LETTERS[1:6])
dag
directed(dag)
skeleton(dag)

Run the code above in your browser using DataLab